Skip to content

Fix SAML authentication when redirect port is occupied - #413

Open
cloudsmith-iduffy wants to merge 1 commit into
masterfrom
cloudsmith-iduffy-redirect-port-fallback
Open

Fix SAML authentication when redirect port is occupied#413
cloudsmith-iduffy wants to merge 1 commit into
masterfrom
cloudsmith-iduffy-redirect-port-fallback

Conversation

@cloudsmith-iduffy

Copy link
Copy Markdown
Contributor

Description

SAML authentication currently fails when local callback port 12400 is occupied. This change tries ports 12400 through 12404 in order, binds the callback server before requesting the IDP URL, and sends the selected redirect URL to the backend so authentication can continue without user intervention.

The callback server is also closed reliably after authentication or an IDP request failure. Backend allowlisting is required for http://localhost:12401 through http://localhost:12404.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactoring
  • Other (please describe)

Additional Notes

Linear: ENG-14026

@cloudsmith-iduffy
cloudsmith-iduffy requested a review from a team as a code owner September 4, 2026 12:40
Copilot AI lite review requested due to automatic review settings September 4, 2026 12:40
@cloudsmith-iduffy
cloudsmith-iduffy force-pushed the cloudsmith-iduffy-redirect-port-fallback branch from dc8fd68 to 07dd0ac Compare September 4, 2026 12:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes CLI SAML authentication failures when the default localhost callback port is already in use by probing a small port range, binding the callback server before fetching the IdP URL, and passing the selected redirect URL through to the backend.

Changes:

  • Add redirect URL support to get_idp_url() so the backend can return an IdP URL tied to the chosen callback port.
  • Update the authenticate command to try ports 12400–12404 and always close the local callback server after success/failure.
  • Extend auth/SAML tests to cover redirect URL wiring and occupied-port behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
cloudsmith_cli/cli/commands/auth.py Probe a port range for the local callback server, pass selected redirect URL to SAML flow, and ensure server closure.
cloudsmith_cli/cli/saml.py Allow callers to specify redirect_url when retrieving the IdP redirect URL.
cloudsmith_cli/cli/tests/commands/test_auth.py Add tests verifying port probing behavior and redirect URL selection.
cloudsmith_cli/cli/tests/test_saml.py Update tests to pass redirect_url to get_idp_url().

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cloudsmith_cli/cli/commands/auth.py Outdated
Comment thread cloudsmith_cli/cli/tests/test_saml.py
Comment thread cloudsmith_cli/cli/commands/auth.py Outdated
@cloudsmith-iduffy
cloudsmith-iduffy force-pushed the cloudsmith-iduffy-redirect-port-fallback branch from 07dd0ac to 8f5d3c8 Compare September 4, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants